<template>
  <a-form ref="passwordFormRef" :rules="passwordRules" :model="passwordForm" @submit="handleSubmit">
    <a-form-item v-for="(item, index) in passwordList" :key="index" :field="item.field" :label="item.label" :validate-trigger="['blur']">
      <a-input v-model="passwordForm[item.field]" :placeholder="item.placeholder" />
    </a-form-item>
    <a-form-item>
      <a-space :size="30">
        <a-button type="primary" @click="save">保存</a-button>
        <a-button type="primary" status="danger" @click="close">关闭</a-button>
      </a-space>
    </a-form-item>
  </a-form>
</template>

<script>
import importConfig from './resetPsw.ts';
import { toRefs } from 'vue';

export default {
  name: 'ResetPsw',
  props: {
    user: {
      type: Object,
      default: null,
    },
  },
  setup(props) {
    const { base, passwordRules, passwordForm, passwordList, save, close } = importConfig(props);

    return {
      ...toRefs(base),
      passwordRules,
      passwordForm,
      passwordList,
      save,
      close,
    };
  },
};
</script>

<style scoped></style>
